package com.heima.wemedia.controller.v1;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.support.MultipartFilter;

@RestController
@RequestMapping("/api/v1/material")
@Slf4j
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile) {
        log.info("上传图片:{}", multipartFile);

        ResponseResult responseResult = wmMaterialService.uploadPicture(multipartFile);
        return responseResult;
    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmMaterialDto dto) {
//        log.info("分页数:{},大小:{}", page,size);
        log.info("分页数:{},大小:{}", dto.getPage(),dto.getSize());
        return wmMaterialService.findList(dto);
    }

}
